<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>destructuring</title>
</head>
<body>
<script>
    // 原来
    /*function fn1(x,y) {
        return x+y;
    }
    fn1(1,2)*/
    // 解构赋值 es6
    /*function fn1([x,y]) {
        return x+y;
    }
    console.log(fn1([1, 2])); //3*/
//    使用默认值
    function fn1({x=0,y=0}={}) {
        return [x,y];
    }
    console.log(fn1({x:100,y:200})); //300
    console.log(fn1({x:100})); //300
    console.log(fn1()); //300
</script>
</body>
</html>